import pandas as pd
df = pd.read_csv('merge.csv')
df['create_time'] = pd.to_datetime(df['create_time'])

df['年份'] = df['create_time'].dt.year
df['月份'] = df['create_time'].dt.month
df['季度'] = (df['月份'] - 1) // 3 + 1
grouped = df.groupby(['年份','季度','月份', 'nick_name_y'])['jz'].sum().reset_index()
top_sales_managers = grouped.loc[grouped.groupby(['年份','季度','月份'])['jz'].idxmax()]
# 准备将结果写入CSV文件
top_sales_managers.to_csv('top_sales_managers.csv')
print(top_sales_managers)
